package simulation;

public class ProjectionAreaOf3dShapes883 {
    public int projectionArea(int[][] grid) {
        int x = 0;
        int y = 0;
        int z = 0;
        for (int i = 0; i < grid.length; i++) {
            int m = 0;
            for (int j = 0; j < grid[i].length; j++) {
                m = Math.max(m,grid[i][j]);
                if(grid[i][j]!=0){
                    x++;
                }
            }

            y+=m;
        }


        for (int i = 0; i < grid[0].length; i++) {
            int m = 0;
            for (int j = 0; j < grid.length; j++) {
                m = Math.max(m,grid[j][i]);
            }
            z+=m;
        }
        
        return x+y+z;
    }
}
